package com.jxauaia.contest.controller;

import com.jxauaia.contest.common.response.PageResult;
import com.jxauaia.contest.common.response.Result;
import com.jxauaia.contest.model.dto.CompPageQueryDTO;
import com.jxauaia.contest.model.vo.ContestDetailVO;
import com.jxauaia.contest.service.ContestDetailService;
import com.jxauaia.contest.service.ContestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/user/comp")
public class ContestController {

    @Autowired
    private ContestService contestService; // 使用contestService
    
    @Autowired
    private ContestDetailService contestDetailService; // 使用contestDetailService

    //比赛分页查询
    @GetMapping("/page")
    public Result<PageResult> page(CompPageQueryDTO compPageQueryDTO){
        log.info("比赛分页查询:{}", compPageQueryDTO);
        PageResult pageResult = contestService.pageQuery(compPageQueryDTO); // 这里正确使用了contestService
        return Result.success(pageResult);
    }

    //查看比赛详情
    @GetMapping("/{id}")
    public Result<ContestDetailVO> getById(@PathVariable Long id){
        log.info("根据id查看比赛详情:{}", id);
        ContestDetailVO contestDetailVO = contestDetailService.getById(id); // 这里正确使用了contestDetailService
        return Result.success(contestDetailVO);
    }
}

